package iso3.pt.action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import iso3.pt.dao.IncorrectPasswordException;
import iso3.pt.dao.UserNotFoundException;
import iso3.pt.model.Alumno;
import iso3.pt.model.Asignatura;
import iso3.pt.model.Evaluacion;
import iso3.pt.model.Profesor;
import iso3.pt.service.PtDaoService;
import iso3.pt.service.PtService;

import java.util.Map;
import java.util.Set;


public class UnassignTeachersAction  extends ActionSupport 
{

	private static final long serialVersionUID = 1L;
	
	private int idAsig;

	private Alumno alumno = null;
	private Set<Asignatura> subjects = null;

	public String execute() throws Exception 
	{
		PtService service = new PtDaoService();
		
		service.getAsignatura(getIdAsig()).setProfesor(null);
		
		@SuppressWarnings("rawtypes")
		Map session = ActionContext.getContext().getSession();
		alumno = (Alumno) session.get("alumno");
		subjects = (Set<Asignatura>) service.getAsignaturas(alumno.getDni());
		
		return SUCCESS;
	}
	
	public int getIdAsig()
	{
		return idAsig;
	}

	public void setIdAsig(int idAsig)
	{
		this.idAsig = idAsig;
	}
	
	public Alumno getAlumno()
	{
		return alumno;
	}

	public void setAlumno(Alumno alumno)
	{
		this.alumno = alumno;
	}

	public Set<Asignatura> getSubjects()
	{
		return subjects;
	}

	public void setSubjects(Set<Asignatura> subjects)
	{
		this.subjects = subjects;
	}
}
